const multer = require('multer');
const storage = multer.diskStorage({
    destination: function(req, file, cb) {
        cb(null, './public/uploads/')
    },
    filename: function(req, file, cb) {
        // console.log(file);
        let i = file.originalname.lastIndexOf('.');
        const uniqueSuffix = Date.now();
        cb(null, file.originalname.substring(0, i) + '-' + uniqueSuffix + '.' + file.originalname.substring(i + 1))
    }
})

const upload = multer({ storage: storage })

module.exports = upload;